﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master_Page/NovaMaster.master" ClientIDMode="Static"
    AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Consultar_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../Style/GridView.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/GridView.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <link href="../Style/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery.autocomplete.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#TbUsuario").autocomplete("AutoCompleteUsuario.ashx");
            $("#TbEstacao").autocomplete("AutoCompleteEstacao.ashx");
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1>
        Consultar Chamados</h1>
    <br />
    <h3>
        <asp:Literal ID="NumChamados" runat="server"></asp:Literal></h3>
    <p>
        Todos Chamados de &nbsp;
        <asp:DropDownList ID="DdlAno" runat="server" Width="80px">
        </asp:DropDownList>
        /
        <asp:DropDownList ID="DdlMes" runat="server" Width="100px">
        </asp:DropDownList>
        &nbsp;<asp:ImageButton ID="ImageButton1" runat="server" Height="28px" ImageAlign="Bottom"
            ImageUrl="~/Images/Atualizar.png" Width="28px" OnClick="ImageButton1_Click" EnableViewState="False" />
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <%=GridView1.Rows.Count.ToString()%> Chamados encontrados
    </p>
    <p>
        <table>
            <tr align="left" valign="baseline">
                <td>&nbsp;&nbsp;&nbsp;
                    Usuário
                </td>
                <td>&nbsp;&nbsp;&nbsp;
                    Estação
                </td>
                <td>&nbsp;&nbsp;&nbsp;
                    Assunto
                </td>
                <td>&nbsp;&nbsp;&nbsp;
                    Tecnico
                </td>
                <td>&nbsp;&nbsp;&nbsp;
                    Situação
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="TbUsuario" runat="server" Width="165px"></asp:TextBox>
                </td>
                <td>
                    <asp:TextBox ID="TbEstacao" runat="server" Width="165px"></asp:TextBox>
                </td>
                <td>
                    <asp:TextBox ID="TbAssunto" runat="server" Width="165px"></asp:TextBox>
                </td>
                <td>
                    <asp:DropDownList ID="DdlTecnico" runat="server" Width="165px"></asp:DropDownList>
                </td>
                <td>
                    <asp:DropDownList ID="DdlSituacao" runat="server" Width="165px"></asp:DropDownList>
                </td>
            </tr>
        </table>
    </p>    <br />
    <p align="right"><asp:LinkButton ID="LBExportar" runat="server" 
            onclick="LBExportar_Click" Visible="False">Exportar para excel</asp:LinkButton></p>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Codigo"
        EnableModelValidation="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
        EnableViewState="False">
        <AlternatingRowStyle CssClass="linha1" />
        <Columns>
            <asp:BoundField DataField="Codigo" HeaderText="Codigo" InsertVisible="False" ReadOnly="True"
                SortExpression="Codigo" />
            <asp:BoundField DataField="Usuario" HeaderText="Usuario" SortExpression="Usuario" />
            <asp:BoundField DataField="Estacao" HeaderText="Estacao" SortExpression="Estacao" />
            <asp:BoundField DataField="Assunto" HeaderText="Assunto" SortExpression="Assunto" />
            <asp:BoundField DataField="Tecnico" HeaderText="Tecnico" SortExpression="Tecnico" />
            <asp:BoundField DataField="Situacao" HeaderText="Situacao" SortExpression="Situacao" />
            <asp:BoundField AccessibleHeaderText="Data Abertura" DataField="DataAbertura" DataFormatString="{0:dd/MM/yyyy}"
                HeaderText="Data de Abertura" />
            <asp:CommandField SelectText="Detalhes" ShowSelectButton="True" />
        </Columns>
        <RowStyle CssClass="linha2" />
        <SelectedRowStyle CssClass="grid_selecionada" />
    </asp:GridView>
    <asp:SqlDataSource ID="Chamados" runat="server" ConnectionString="<%$ ConnectionStrings:chamados %>"
        ProviderName="<%$ ConnectionStrings:chamados.ProviderName %>" SelectCommand="SELECT chamados.codigo AS Codigo, usuarios.nome AS Usuario, chamados.estacao AS Estacao, chamados.assunto AS Assunto, tecnicos.nome AS Tecnico, situacao.descricao AS Situacao, chamados.data_abertura AS DataAbertura FROM chamados INNER JOIN usuarios ON chamados.solicitante = usuarios.codigo INNER JOIN tecnicos ON chamados.Tecnicos_codigo = tecnicos.codigo INNER JOIN situacao ON chamados.Situacao_codigo = situacao.codigo">
    </asp:SqlDataSource>
</asp:Content>